package com.streamsets.datacollector.pileline.enums;

/**
 * @author wengzhonghui
 * @date 2019/10/16 19:04
 */
public enum SourceConfigEnum {

    // 例如：jdbc:mysql://172.30.0.9:3306/test_performance
    jdbcConnectionString("hikariConfigBean.connection.connectionString",""),
    username("hikariConfigBean.connection.username",""),
    password("hikariConfigBean.connection.password",""),

    // 有些地方特例，会加上config前缀
    config_jdbcConnectionString("config.hikariConfigBean.connection.connectionString",""),
    config_username("config.hikariConfigBean.connection.username",""),
    config_password("config.hikariConfigBean.connection.password",""),

    isIncrementalMode("isIncrementalMode",false),
    // 抽取查询的地址
    query("query",""),
    initialOffset("initialOffset","1970-08-27 13:48:26"),
    offsetColumn("offsetColumn","modified_date"),
    driverClassName("driverClassName",""),
    queryInterval("queryInterval","${10* SECONDS}");


     SourceConfigEnum(String name, Object defaultValue) {
        this.name = name;
        this.defaultValue = defaultValue;
    }
    private String name;

    private Object defaultValue;

    public static SourceConfigEnum valueOfName(String name){
        for(SourceConfigEnum type : SourceConfigEnum.class.getEnumConstants()){
            if (name.equalsIgnoreCase(type.getName())){
                return type;
            }

        }
        throw new IllegalArgumentException("name:" + name + " is not a valid "
                + "Types.java value.");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Object getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(Object defaultValue) {
        this.defaultValue = defaultValue;
    }
}
